<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加菜单</title>
    <link rel="stylesheet" th:href="@{/layui-v2.6.8/css/layui.css}" href="/static/layui-v2.6.8/css/layui.css">
</head>
<body>
<div style="padding: 15px;">
    <form class="layui-form form-position" action="/amin/menu/createMenu" method="post" id="from-data">
<!--
        <input type="text" name="menuId" th:field="${menuId}" style="display: none;">
-->
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-block">
                <input type="text" name="menuName" th:field="${menu.menuName}" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input layui-input-width">
                <input type="text" name="id" th:field="${menu.id}" style="display: none" placeholder="请输入" autocomplete="off" class="layui-input layui-input-width">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上级菜单</label>
            <div class="layui-input-block">
                <select name="parentId" lay-filter="aihao"  th:field="${menu.parentId}" >
                    <option th:each="menuList:${menuList}" th:value="${menuList.id}" th:text="${menuList.menuName}">本站</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">菜单链接</label>
            <div class="layui-input-block">
                <input type="text" name="menuHref" th:field="${menu.menuHref}" required  lay-verify="required" placeholder="请输入菜单链接" autocomplete="off" class="layui-input layui-input-width">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">跳转方式</label>
            <div class="layui-input-block">
                <select name="jumpMode" lay-filter="aihao" th:field="${menu.jumpMode}">
                    <option value="0" selected="">本站</option>
                    <option value="1">外站</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
        <label class="layui-form-label">菜单类型</label>
        <div class="layui-input-block">
            <input type="radio" name="menuType" th:each="dictState,dictStateStat:${systemMenuType}"  required  lay-verify="required" th:field="${menu.menuType}" th:value="${dictState.dictKey}" th:title="${dictState.dictTitle}" checked="">
        <!--    <select name="menuType" lay-filter="aihao">
                <option value="0" selected="">菜单</option>
                <option value="1">按钮</option>
            </select>-->
        </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">打开方式</label>
            <div class="layui-input-block">
                <select name="openType" lay-filter="aihao" th:field="${menu.openType}">
                    <option value="home-page" selected="">站内</option>
                    <option value="1">网页</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单序号</label>
            <div class="layui-input-block">
                <input type="text" name="sort" th:field="${menu.sort}" required  lay-verify="required" placeholder="请输入菜单序号" autocomplete="off" class="layui-input layui-input-width">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formSubmit">保存</button>
                <button type="reset" th:if="${menu.id == null}" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>
</div>
</body>
<script th:src="@{/layui-v2.6.8/layui.js}" src="/static/layui-v2.6.8/layui.js"></script>
<script th:src="@{/jquery-3.5.1/jquery-3.5.1.min.js}" src="/static/jquery-3.5.1/jquery-3.5.1.min.js"></script>
<script th:src="@{/ajaxSubmit.js}" src="/static/jquery-3.5.1/jquery-3.5.1.min.js"></script>
<script>
    layui.use(function(){
        var layer = layui.layer
            ,form = layui.form;
        //layer.msg('Hello World');
        //监听提交
        form.on('submit(formSubmit)', function(data){
            // $("#form_submit_button_01").attr('disabled',false);
            var url = '/amin/menu/dataSubmit';
            var data =$("#from-data").serialize();
            layer.msg('操作成功，正在跳转......');
            ajaxSubmit(url,data,"","");
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.location.reload();
            parent.layer.close(index);
        });
    });
</script>
</html>